home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / '92_HACK / CHANGE_T / TICKLE.C < prev   
Text File  |  1992-05-24  |  2KB  |  67 lines

  1. /*
  2. ** From: dickie@schaefer.math.wisc.edu (Garth Dickie)
  3. ** Newsgroups: comp.sys.mac.programmer
  4. ** Subject: Re: HOW do I get the finder to update its file information..
  5. ** Message-ID: <1992May22.014427.9977@schaefer.math.wisc.edu>
  6. ** Date: 22 May 92 01:44:27 GMT
  7. ** References: <1992May21.231246.23090@crash.cts.com>
  8. ** Organization: Univ. of Wisconsin Dept. of Mathematics
  9. ** Lines: 58
  10. ** 
  11. ** You need to change the modification date of the parent directory.
  12. ** The routine TickleParent below works for me.  In case you are not
  13. ** using the FSSpec structure, the routine MakeWDSpec will convert
  14. ** a working directory / filename pair to a psuedo-FSSpec.  I use
  15. ** this when the new file manager calls are not available, as the rest
  16. ** of my code passes around FSSpecs.  The code compiles under THINK C
  17. ** 5.0, with the usual headers.
  18. ** 
  19. ** BTW (mild flame) this is simple enough that it's pretty annoying
  20. ** when people don't do it.  Most of the nifty little 'drag-and-drop'
  21. ** utilities that have come around recently forget to do this.  Feel
  22. ** free to use the code below in any way you see fit.
  23. */
  24.  
  25. OSErr TickleParent( FSSpec * child ) {
  26.     CInfoPBRec    pb;
  27.     OSErr         err = noErr;
  28.  
  29.     pb.dirInfo.ioCompletion = 0;
  30.     pb.dirInfo.ioNamePtr = 0;
  31.     pb.dirInfo.ioVRefNum = child->vRefNum;
  32.     pb.dirInfo.ioFDirIndex = -1;              // get info based on the DirID
  33.     pb.dirInfo.ioDrDirID = child->parID;
  34.     
  35.     if(( err = PBGetCatInfoSync( &pb )) != noErr ) return err;
  36.  
  37.     GetDateTime( &pb.dirInfo.ioDrMdDat );
  38.  
  39.     err = PBSetCatInfoSync( &pb );
  40.  
  41.     return err;
  42. }
  43.  
  44. OSErr MakeWDSpec( FSSpec *spec, short vRefNum, ConstStr255Param name ) {
  45.     WDPBRec          parameter;
  46.     Size             length;
  47.     OSErr            err;
  48.     
  49.     parameter.ioCompletion = 0;
  50.     parameter.ioNamePtr = 0;
  51.     parameter.ioVRefNum = vRefNum;
  52.     parameter.ioWDIndex = 0;
  53.     parameter.ioWDProcID = 0;
  54.     parameter.ioWDVRefNum = 0;
  55.  
  56.     err = PBGetWDInfoSync( ¶meter );
  57.  
  58.     spec->vRefNum = parameter.ioWDVRefNum;
  59.     spec->parID = parameter.ioWDDirID;
  60.  
  61.     length = (( *name > sizeof spec->name - 1 )? *name : sizeof spec->name -1);
  62.     BlockMove( name + 1, spec->name + 1, length );
  63.     *spec->name = length;
  64.     
  65.     return err;
  66. }
  67.